package net.sureon.web.user;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import net.sureon.app.UserSession;
import net.sureon.biz.ApplicationMgr;
import net.sureon.dao.Application;

import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.servlet.mvc.Controller;

/**
 * 审核申请类
 * 
 * @author Administrator
 * 
 */
public class ConfirmApplication implements Controller {
	private ApplicationMgr applicationMgr;

	public ModelAndView handleRequest(HttpServletRequest request,
			HttpServletResponse response) throws Exception {

		Application app = new Application();
		long userID = ((net.sureon.app.UserSession) request.getSession()
				.getAttribute(UserSession.HTTP_SESSION_KEY)).getUserID();
		long companyID = ((net.sureon.app.UserSession) request.getSession()
				.getAttribute(UserSession.HTTP_SESSION_KEY)).getCompanyID();
		long applicationID = Long.parseLong(request
				.getParameter("applicationID"));

		applicationMgr.updateApplication(companyID, applicationID, new java.util.Date(), userID, "OK", "Approved");

		response.sendRedirect(request.getContextPath()
				+ "/user/underlingApplication.do");
		return null;
	}

	public ApplicationMgr getApplicationMgr() {
		return applicationMgr;
	}

	public void setApplicationMgr(ApplicationMgr applicationMgr) {
		this.applicationMgr = applicationMgr;
	}
}
